<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Phrase Definitions</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Phrase Definitions' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Extensions</a></li><li><a href="index.html">Basic Inform</a></li><li><b>Phrase Definitions</b></li></ul></div>
<p class="purpose">The phrases making up the basic Inform language, and in terms of which all other phrases and rules are defined.</p>

<ul class="toc"><li><a href="phdf.html#SP4">&#167;4. Say phrases</a></li><li><a href="phdf.html#SP13">&#167;13. Variables</a></li><li><a href="phdf.html#SP16">&#167;16. Arithmetic</a></li><li><a href="phdf.html#SP22">&#167;22. Control structures</a></li><li><a href="phdf.html#SP31">&#167;31. Values</a></li><li><a href="phdf.html#SP34">&#167;34. Text</a></li><li><a href="phdf.html#SP39">&#167;39. Adaptive text</a></li><li><a href="phdf.html#SP40">&#167;40. Data Structures</a></li><li><a href="phdf.html#SP43">&#167;43. Lists</a></li><li><a href="phdf.html#SP49">&#167;49. Functional Programming</a></li><li><a href="phdf.html#SP51">&#167;51. Rulebooks and Activities</a></li><li><a href="phdf.html#SP55">&#167;55. Basic IO</a></li><li><a href="phdf.html#SP63">&#167;63. External Files</a></li><li><a href="phdf.html#SP66">&#167;66. Use Options</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>All phrases of the Inform language itself are defined here. The Standard
Rules extension adds more, specialised for interactive fiction creation,
but the bones of the language are here. For example, we will define what
the plus sign will mean, and how Inform should compile "say N in words",
where N is a number. Inform has no phrase definitions built in, as such;
but it does contain assumptions about control structures such as "say ...",
"repeat ...", "let ...", "otherwise ..." and so on will behave. Those, we
would not be able to redefine in fundamentally different ways. In most
respects, though, we are more or less free to define any language we like.
</p>

<p class="commentary">At first sight, these phrase definitions look little more than simple
transliterations, and this was one source of early criticism of Inform 7.
Phrases appeared to have very simplistic definitions, with the natural
language simply being a verbose description of obviously equivalent C-like
code. However, the simplicity is misleading, because the definitions below
tend to conceal where the complexity of the translation process suddenly
increases. If the preamble includes "(c - condition)", and the definition
includes the expansion <span class="extract"><span class="extract-syntax">{c}</span></span>, then the text forming c is translated in a way
much more profound than any simple substitution process could describe.
Type-checking also complicates the code produced below, since Inform
automatically generates the code needed to perform run-time type checking at
any point where doubt remains as to the phrase definition which must be used.
</p>

<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Many of these phrases have what are called inline definitions, written
using the <span class="extract"><span class="extract-syntax">(-</span></span> and <span class="extract"><span class="extract-syntax">-)</span></span> notation. Non-inline phrases are compiled as
functions, which are then called when they need to be used. For example,
"To say the magic number: say 17." compiles to a function, and when
another phrase includes the instruction "say the magic number", that
instruction compiles a call to this function. But an inline phrase
instead generates Inter instructions to do something directly. (That
something may in fact still be just a function call, but not always.)
The Inter code to be generated is expressed by the contents of the
definition between the <span class="extract"><span class="extract-syntax">(-</span></span> and <span class="extract"><span class="extract-syntax">-)</span></span> markers, and is written in a
marked-up form of Inform 6 notation. This is much more concise and
readable than if the Inter code were written out longhand, but it may
give the misleading impression that Inform inline definitions can only
produce Inform 6 code. That is not so: they produce Inter code, which
can then be translated as needed.
</p>

<p class="commentary">Most of the definitions here also have annotations to positions in the
main Inform documentation: for example, <span class="extract"><span class="extract-syntax">(documented at phs_s)</span></span>. This has
no effect on the code compiled, and is used only when Inform generates
certain problem messages; if the source text misuses the phrase, the problem
can then give a reference to the relevant documentation. <span class="extract"><span class="extract-syntax">phs_s</span></span> is a
typical example of a "documentation token", and is only a label. See the
source of the Inform documentation for how this markup is done.
</p>

<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Unit tests for the phrases below have test case names beginning <span class="extract"><span class="extract-syntax">BIP-</span></span>,
which stands for "Basic Inform phrase". In fact, these come in pairs, one for
each virtual machine we customarily generate code to. For example, <span class="extract"><span class="extract-syntax">BIP-Say</span></span>
tests the "say" phrase for the Z-machine target, and <span class="extract"><span class="extract-syntax">BIP-Say-G</span></span> does the same
for the Glulx target. But in the commentary below, test cases will be listed
only once.
</p>

<p class="commentary">It follows that running <span class="extract"><span class="extract-syntax">intest -from inform7 BIP-%c+</span></span> will test all of
these phrases on all platforms, since this regular expression matches all
test case names beginning with "BIP-".
</p>

<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Say phrases.</b>We begin with saying phrases: the very first phrase to exist is the one
printing a single value &mdash; literal text, a number, a time, an object, or
really almost anything, since the vast majority of kinds in Inform are
sayable. There used to be separate definitions for saying text, numbers
and unicode characters here, but they were removed in June 2015 as being
redundant. Though they did no harm, they made some problem messages longer
than necessary by obliging them to cite a longer list of possible readings
of a misread phrase.
</p>

<p class="commentary">The three inline definitions here neatly demonstrate the three sorts of
things which appear inside <span class="extract"><span class="extract-syntax">(-</span></span> and <span class="extract"><span class="extract-syntax">-)</span></span>. The definition for "To say s",
which looks more familiar as the "[s]" text substitution, is straightforwardly
Inform 6 notation. The definition for "To say (something - number) in words"
is I6 notation except for the <span class="extract"><span class="extract-syntax">{something}</span></span> part in braces: this expands
to the value used by the code causing compilation. For example, if the code
to be compiled is "say 17 in words" then <span class="extract"><span class="extract-syntax">{something}</span></span> here would expand to
the constant 17. The definition for "To say (val)" is much more complex than
I6 notation could convey, and so a more complex escape notation is needed,
<span class="extract"><span class="extract-syntax">{-say:val:K}</span></span>, which tells Inform to compile code which will say <span class="extract"><span class="extract-syntax">val</span></span> with
whatever method is appropriate to its kind <span class="extract"><span class="extract-syntax">K</span></span>. For documentation on these
escape notations, see the core Inform source code.
</p>

<p class="commentary">The global variable <span class="extract"><span class="extract-syntax">say__n</span></span> tracks the last number printed. For the "in
words" definition, we need to set it by hand, since Inform doesn't otherwise
realise that number-printing is what we are doing here. For definitions of
functions such as <span class="extract"><span class="extract-syntax">STextSubstitution</span></span>, see the source for <span class="extract"><span class="extract-syntax">BasicInformKit</span></span>,
which is also where <span class="extract"><span class="extract-syntax">say__n</span></span> is defined.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Say</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Part</span><span class="plain-syntax"> </span><span class="identifier-syntax">Three</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Phrasebook</span>

<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Values</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">sayable</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_say</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">say</span><span class="plain-syntax">:</span><span class="identifier-syntax">val</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">words</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_numwords</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">say__n</span><span class="plain-syntax">=({</span><span class="identifier-syntax">something</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">s</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_s</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">STextSubstitution</span><span class="plain-syntax">(); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>"Showme" is a debugging version of "say" which can print some version of
the value, and the kind, of just about anything.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Showme</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">showme</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_showme</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">show</span><span class="plain-syntax">-</span><span class="identifier-syntax">me</span><span class="plain-syntax">:</span><span class="identifier-syntax">val</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>Now some fun with number bases:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">hexadecimal</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">16</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">decimal</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">10</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">octal</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">8</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">binary</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">2</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">base</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">B</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_indigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">10</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">hexadecimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbaseindigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">16</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbaseindigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">10</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">octal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbaseindigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">8</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">binary</span><span class="plain-syntax"> </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbaseindigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">2</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">base</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inbaseindigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">B</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">unsigned</span><span class="plain-syntax"> </span><span class="identifier-syntax">decimal</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inunsigneddecimal</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">10</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">unsigned</span><span class="plain-syntax"> </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digit</span><span class="plain-syntax">/</span><span class="identifier-syntax">digits</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_inunsigneddecimaldigits</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">PrintInBase</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">10</span><span class="plain-syntax">, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>Objects are the most difficult things to say, because of the elaborate
apparatus for managing their natural-language representations. In particular,
we need to say them with a definite or indefinite article, which can either
be capitalised or not, and as part of that we need to keep track of whether
they are proper nouns; in languages other than English, there are also gender
and case to worry about.
</p>

<p class="commentary">Note that "To say ..." phrases are case sensitive on the first word, so that
"to say a something" and "to say A something" are different.
</p>

<p class="commentary">A curiosity of Inform 6's syntax, arising I think mostly from the need to
save property memory in "Curses" (1993), the work of IF for which Inform 1
had been created, is that it lacks a <span class="extract"><span class="extract-syntax">print (A) ...</span></span> statement. The omission
is made good by using a routine in the template library instead.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayName</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Names</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_a</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">a</span><span class="plain-syntax">) {</span><span class="identifier-syntax">something</span><span class="plain-syntax">}; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_a</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">a</span><span class="plain-syntax">) {</span><span class="identifier-syntax">something</span><span class="plain-syntax">}; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_A</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">CIndefArt</span><span class="plain-syntax">({</span><span class="identifier-syntax">something</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">An</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_A</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">CIndefArt</span><span class="plain-syntax">({</span><span class="identifier-syntax">something</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_the</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">the</span><span class="plain-syntax">) {</span><span class="identifier-syntax">something</span><span class="plain-syntax">}; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">The</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_The</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">The</span><span class="plain-syntax">) {</span><span class="identifier-syntax">something</span><span class="plain-syntax">}; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>Now some text substitutions which are the equivalent of escape characters.
(In double-quoted I6 text, the notation for a literal quotation mark is a
tilde <span class="extract"><span class="extract-syntax">~</span></span>.) Note the use of the "-- running on" annotation, which tells Inform
that a text substitution should not cause a new-line.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SaySpecial</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Special</span><span class="plain-syntax"> </span><span class="identifier-syntax">Characters</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">bracket</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_bracket</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> "["; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">close</span><span class="plain-syntax"> </span><span class="identifier-syntax">bracket</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_closebracket</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> "]"; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">apostrophe</span><span class="plain-syntax">/' -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_apostrophe</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> "'"; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">quotation</span><span class="plain-syntax"> </span><span class="identifier-syntax">mark</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_quotemark</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">print</span><span class="plain-syntax"> "~"; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>For an explanation of the paragraph breaking algorithm, see the template
file "Printing.i6t".
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayParagraphing</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Line</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">Breaks</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_linebreak</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">new_line</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">no</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_nolinebreak</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">do</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">conditional</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_condparabreak</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">DivideParagraphPoint</span><span class="plain-syntax">(); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_parabreak</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">DivideParagraphPoint</span><span class="plain-syntax">(); </span><span class="identifier-syntax">new_line</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">run</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_runparaon</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RunParagraphOn</span><span class="plain-syntax">(); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">pending</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_breakpending</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">say__p</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>Now for "[if ...]", which expands into a rather assembly-language-like
usage of <span class="extract"><span class="extract-syntax">jump</span></span> statements, I6's form of goto. For instance, the text
"[if the score is 10]It's ten![otherwise]It's not ten, alas." compiles
thus:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">score</span><span class="plain-syntax"> == </span><span class="constant-syntax">10</span><span class="plain-syntax">)) </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_Say3</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        ...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_SayX2</span><span class="plain-syntax">; .</span><span class="identifier-syntax">L_Say3</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        ...</span>
<span class="plain-syntax">    .</span><span class="identifier-syntax">L_Say4</span><span class="plain-syntax">; .</span><span class="identifier-syntax">L_SayX2</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary">Though labels actually have local namespaces in I6 routines, we use
globally unique labels throughout the whole program: compiling the same
phrase again would involve say labels 5 and 6 and "say exit" label 3.
This example text demonstrates the reason we <span class="extract"><span class="extract-syntax">jump</span></span> about, rather than
making use of <span class="extract"><span class="extract-syntax">if... else...</span></span> and bracing groups of statements: it is legal
in I7 either to conclude with or to omit the "[end if]". (If statements
in I6 compile to jump instructions in any event, and on our virtual
machines there is no speed penalty for branches.) We also need the same
definitions to accommodate what amounts to a switch statement. The trickier
text "[if the score is 10]It's ten![otherwise if the score is 8]It's
eight?[otherwise]It's not ten, alas." comes out as:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">score</span><span class="plain-syntax"> == </span><span class="constant-syntax">10</span><span class="plain-syntax">)) </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_Say5</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        ...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_SayX3</span><span class="plain-syntax">; .</span><span class="identifier-syntax">L_Say5</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">score</span><span class="plain-syntax"> == </span><span class="constant-syntax">8</span><span class="plain-syntax">)) </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_Say6</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        ...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">L_SayX3</span><span class="plain-syntax">; .</span><span class="identifier-syntax">L_Say6</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        ...</span>
<span class="plain-syntax">    .</span><span class="identifier-syntax">L_Say7</span><span class="plain-syntax">; .</span><span class="identifier-syntax">L_SayX3</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary">In either form of the construct, control passes into at most one of the
pieces of text. The terminal labels (the two on the final line) are
automatically generated; often &mdash; when there is a simple "otherwise" or
"end if" to conclude the construct &mdash; they are not needed, but labels are
quick to process in I6, are soon discarded from I6's memory when not needed
any more, and compile no code.
</p>

<p class="commentary">We assume in each case that the next say label number to be free is always
the start of the next block, and that the next say exit label number is always
the one at the end of the current construct. This is true because Inform does
not allow "say if" to be nested.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayIf</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">If</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Otherwise</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_if</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (~~({</span><span class="identifier-syntax">c</span><span class="plain-syntax">})) </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">unless</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_unless</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> ({</span><span class="identifier-syntax">c</span><span class="plain-syntax">}) </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">otherwise</span><span class="plain-syntax">/</span><span class="identifier-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_elseif</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}; </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (~~({</span><span class="identifier-syntax">c</span><span class="plain-syntax">})) </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">otherwise</span><span class="plain-syntax">/</span><span class="identifier-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">unless</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_elseunless</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}; </span><span class="identifier-syntax">if</span><span class="plain-syntax"> ({</span><span class="identifier-syntax">c</span><span class="plain-syntax">}) </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">otherwise</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_otherwise</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">else</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_otherwise</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">jump</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_endif</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">unless</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_endunless</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">Say</span><span class="plain-syntax">}; .{-</span><span class="identifier-syntax">label</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">SayX</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>The other control structure: the random variations form of saying. This
part of the Inform design was in effect contributed by the community: it
reimplements a form of Jon Ingold's former extension Text Variations, which
itself built on code going back to the days of I6.
</p>

<p class="commentary">The head phrase has one of the most complicated definitions suppled with
Inform, but is actually documented fairly explicitly in the Extensions chapter
of "Writing with Inform", so we won't repeat all that here. Essentially it
uses its own allocated cell of storage in an array to remember a state between
uses, and compiles as a switch statement based on the current state.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayOneOf</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">one</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">one</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">beginning</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_oneof</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">    {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">makes</span><span class="plain-syntax">-</span><span class="identifier-syntax">array</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">makes</span><span class="plain-syntax">-</span><span class="identifier-syntax">array</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">} == </span><span class="identifier-syntax">false</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">} = {-</span><span class="identifier-syntax">final</span><span class="plain-syntax">-</span><span class="identifier-syntax">segment</span><span class="plain-syntax">-</span><span class="identifier-syntax">marker</span><span class="plain-syntax">}({-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">segment</span><span class="plain-syntax">-</span><span class="identifier-syntax">count</span><span class="plain-syntax">});</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">} = </span><span class="identifier-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say__comp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">false</span><span class="plain-syntax">) {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_flag</span><span class="plain-syntax">} = </span><span class="identifier-syntax">false</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">switch</span><span class="plain-syntax"> (({-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax">})%({-</span><span class="identifier-syntax">segment</span><span class="plain-syntax">-</span><span class="identifier-syntax">count</span><span class="plain-syntax">}+1)-1)</span>
<span class="plain-syntax">{-</span><span class="identifier-syntax">open</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        </span><span class="constant-syntax">0</span><span class="plain-syntax">: -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">or</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">continuing</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_or</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">segment</span><span class="plain-syntax">-</span><span class="identifier-syntax">count</span><span class="plain-syntax">}: -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_RAN</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_random</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">purely</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_PAR</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_purelyrandom</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">then</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_TRAN</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_thenrandom</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">then</span><span class="plain-syntax"> </span><span class="identifier-syntax">purely</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_TPAR</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_thenpurelyrandom</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">sticky</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_STI</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_sticky</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">decreasingly</span><span class="plain-syntax"> </span><span class="identifier-syntax">likely</span><span class="plain-syntax"> </span><span class="identifier-syntax">outcomes</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_TAP</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_decreasing</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> </span><span class="identifier-syntax">order</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_SHU</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_order</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">cycling</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_CYC</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_cycling</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">stopping</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_one_of</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">marker</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_STOP</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_stopping</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">time</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">beginning</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_firsttime</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">makes</span><span class="plain-syntax">-</span><span class="identifier-syntax">array</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">say__comp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">false</span><span class="plain-syntax">) &amp;&amp; (({-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">storage</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax">}--&gt;{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax">}{-</span><span class="identifier-syntax">counter</span><span class="plain-syntax">-</span><span class="identifier-syntax">up</span><span class="plain-syntax">:</span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax">})++ == </span><span class="constant-syntax">0</span><span class="plain-syntax">)) {-</span><span class="identifier-syntax">open</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">ending</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_first_time</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_firsttime</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">close</span><span class="plain-syntax">-</span><span class="identifier-syntax">brace</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>These are lists in the sense of the "list of" kind of value constructor, and
the first two phrases here might list any values, not just objects.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayLists</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">7</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Lists</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Values</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">brace</span><span class="plain-syntax"> </span><span class="identifier-syntax">notation</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_listbraced</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Say</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">definite</span><span class="plain-syntax"> </span><span class="identifier-syntax">articles</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_listdef</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Say</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="constant-syntax">2</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">indefinite</span><span class="plain-syntax"> </span><span class="identifier-syntax">articles</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_listindef</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Say</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="constant-syntax">3</span><span class="plain-syntax">); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Variables.</b>The "now" phrase can do an extraordinary range of things, and is more or
less a genie granting one wish.
</p>

<p class="commentary">The "whether or not" phrase exists only to convert a condition to a value,
and is needed because I7 does not silently cast from one to the other in
the way that C would.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Now</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Conditions</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Variables</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Conditions</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">now</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cn</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_now</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">make</span><span class="plain-syntax">-</span><span class="identifier-syntax">true</span><span class="plain-syntax">:</span><span class="identifier-syntax">cn</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">truth</span><span class="plain-syntax"> </span><span class="identifier-syntax">state</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> </span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">not</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_whether</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({</span><span class="identifier-syntax">C</span><span class="plain-syntax">}) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>Assignment is probably the most difficult thing the type-checker has to
cope with, since "let" has to work when applied to both unknown names (it
creates a new variable) and existing ones (kind of value permitting). There
are also four different ways to create with "let", and two to use
existing variables. Note that the "given by" forms are not strictly
speaking assignments at all; the value placed in <span class="extract"><span class="extract-syntax">t</span></span> is found by solving
the equation <span class="extract"><span class="extract-syntax">Q</span></span>. This does require special typechecking, but of a
different kind to that requested by "(assignment operation)". All of which
makes the "To let" section here only slightly shorter than John Galsworthy's
Forsyte novel of the same name.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Let</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Assigning</span><span class="plain-syntax"> </span><span class="identifier-syntax">Temporary</span><span class="plain-syntax"> </span><span class="identifier-syntax">Variables</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> (</span><span class="identifier-syntax">u</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_let</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">unprotect</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">:</span><span class="identifier-syntax">u</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> (</span><span class="identifier-syntax">u</span><span class="plain-syntax"> - </span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_letdefault</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">unprotect</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">initialise</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> (</span><span class="identifier-syntax">u</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">relations</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_letrelation</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">unprotect</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">initialise</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">now</span><span class="plain-syntax">-</span><span class="identifier-syntax">matches</span><span class="plain-syntax">-</span><span class="identifier-syntax">description</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">:</span><span class="identifier-syntax">u</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Q</span><span class="plain-syntax"> - </span><span class="identifier-syntax">equation</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_letequation</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">unprotect</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">solve</span><span class="plain-syntax">-</span><span class="identifier-syntax">equation</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">existing</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> (</span><span class="identifier-syntax">u</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_let</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">t</span><span class="plain-syntax">:</span><span class="identifier-syntax">u</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">let</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">existing</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">) </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Q</span><span class="plain-syntax"> - </span><span class="identifier-syntax">equation</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_letequation</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">solve</span><span class="plain-syntax">-</span><span class="identifier-syntax">equation</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>It is not explicit in the following definitions that Inform should typecheck
that the values held by these storage objects can be incremented or decremented
(as an object, say, cannot, but a number can): Inform nevertheless contains
code which does this.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Increase</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Increase</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Decrease</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">increase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">storage</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_increase</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">S</span><span class="plain-syntax">:+</span><span class="identifier-syntax">w</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decrease</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">storage</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">assignment</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_decrease</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">S</span><span class="plain-syntax">:-</span><span class="identifier-syntax">w</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">increment</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">storage</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_increment</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">S</span><span class="plain-syntax">:+};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decrement</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">storage</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_decrement</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">copy</span><span class="plain-syntax">:</span><span class="identifier-syntax">S</span><span class="plain-syntax">:-};</span>
<span class="plain-syntax">    -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Arithmetic.</b>There are nine arithmetic operations, internally numbered 0 upwards, and
given verbal forms below. These are handled unusually in the type-checker
because they need to be more polymorphic than most phrases: Inform uses
dimension-checking to determine the kind of value resulting. (Thus a
height times a number is another height, and so on.)
</p>

<p class="commentary">The totalling code (12) is not structly to do with arithmetic in the same
way, but it's needed to flag the phrase for the Inform typechecker's special
attention.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-ArithmeticOperations</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Arithmetic</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">Operations</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) + (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_plus</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">plus</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_plus</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) - (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_minus</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">minus</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_minus</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) * (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_times</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">times</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_times</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">multiplied</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_times</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) / (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_divide</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">divided</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_divide</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">remainder</span><span class="plain-syntax"> </span><span class="identifier-syntax">after</span><span class="plain-syntax"> </span><span class="identifier-syntax">dividing</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_remainder</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">nearest</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nearest</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">:</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">square</span><span class="plain-syntax"> </span><span class="identifier-syntax">root</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_squareroot</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">cube</span><span class="plain-syntax"> </span><span class="identifier-syntax">root</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">8</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_cuberoot</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax">-</span><span class="identifier-syntax">operation</span><span class="plain-syntax">:</span><span class="identifier-syntax">X</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">valued</span><span class="plain-syntax"> </span><span class="identifier-syntax">property</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">12</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_total</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">total</span><span class="plain-syntax">-</span><span class="identifier-syntax">of</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>Real numbers are not available in the Z-machine, but they are likely to
be available everywhere else, i.e., on any other platform Inform may target
in future.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayRealNumbers-G</span></span>, which has no Z-machine counterpart.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Real</span><span class="plain-syntax"> </span><span class="identifier-syntax">Numbers</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">places</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_realplaces</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">Float</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">notation</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_decimal</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FloatDec</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">places</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">notation</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_decimalplaces</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FloatDec</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">scientific</span><span class="plain-syntax"> </span><span class="identifier-syntax">notation</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_scientific</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FloatExp</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">decimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">places</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">scientific</span><span class="plain-syntax"> </span><span class="identifier-syntax">notation</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_scientificplaces</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FloatExp</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>A number of miscellaneous mathematical functions follow, for real
numbers only; these are tested as part of <span class="extract"><span class="extract-syntax">BIP-ArithmeticOperations-G</span></span>,
already mentioned above. Note that we do not need to define real versions
of addition, multiplication and so on: the above definitions are polymorphic
enough to have done that already.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Real</span><span class="plain-syntax"> </span><span class="identifier-syntax">Arithmetic</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">reciprocal</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_reciprocal</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Reciprocal</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">absolute</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_absolutevalue</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">abs</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Abs</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">square</span><span class="plain-syntax"> </span><span class="identifier-syntax">root</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">operation</span><span class="plain-syntax"> </span><span class="constant-syntax">7</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_realsquareroot</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">root</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">rsqr</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Root</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">square</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">rsqr</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">root</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R</span><span class="plain-syntax">^2 </span><span class="identifier-syntax">where</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">ceiling</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_ceiling</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">ceiling</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Ceiling</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">floor</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_floor</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">floor</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Floor</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">nearest</span><span class="plain-syntax"> </span><span class="identifier-syntax">whole</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nearestwholenumber</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_to_NUMBER_TY</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>And these are tested in <span class="extract"><span class="extract-syntax">BIP-Exponentials-G</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Exponential</span><span class="plain-syntax"> </span><span class="identifier-syntax">Functions</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">natural</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">logarithm</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_logarithm</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">log</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">exp</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Log</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">logarithm</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">base</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_logarithmto</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_BLog</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">exponential</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_exp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">exp</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">log</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Exp</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">power</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_power</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Pow</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>And these are tested in <span class="extract"><span class="extract-syntax">BIP-Trigonometry-G</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Trigonometric</span><span class="plain-syntax"> </span><span class="identifier-syntax">Functions</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">degrees</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_degrees</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Times</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, $+0.0174532925) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">sine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">sin</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Sin</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">cosine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_cosine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">cos</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccos</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Cos</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">tangent</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_tangent</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">tan</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctan</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Tan</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_arcsine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsin</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">sin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Arcsin</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccosine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_arccosine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccos</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">cos</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Arccos</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctangent</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_arctangent</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctan</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">tan</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Arctan</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>And these are tested in <span class="extract"><span class="extract-syntax">BIP-Hyperbolics-G</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Trigonometric</span><span class="plain-syntax"> </span><span class="identifier-syntax">Functions</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">sine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperbolicsine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">sinh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsinh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Sinh</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">cosine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperboliccosine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">cosh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccosh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Cosh</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">tangent</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperbolictangent</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">tanh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctanh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">REAL_NUMBER_TY_Tanh</span><span class="plain-syntax">({</span><span class="identifier-syntax">R</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperbolicarcsine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arcsinh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">sinh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">log</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax"> + </span><span class="identifier-syntax">root</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">^2 + </span><span class="constant-syntax">1</span><span class="plain-syntax">)) </span><span class="identifier-syntax">where</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccosine</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperbolicarccosine</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arccosh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">cosh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">log</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax"> + </span><span class="identifier-syntax">root</span><span class="plain-syntax">(</span><span class="identifier-syntax">R</span><span class="plain-syntax">^2 - </span><span class="constant-syntax">1</span><span class="plain-syntax">)) </span><span class="identifier-syntax">where</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">hyperbolic</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctangent</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_hyperbolicarctangent</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">arctanh</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">inverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">tanh</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">given</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">.5*(</span><span class="identifier-syntax">log</span><span class="plain-syntax">(1+</span><span class="identifier-syntax">R</span><span class="plain-syntax">) - </span><span class="identifier-syntax">log</span><span class="plain-syntax">(1-</span><span class="identifier-syntax">R</span><span class="plain-syntax">)) </span><span class="identifier-syntax">where</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">real</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. Control structures.</b>The term "control structure" conjures up the thought of conditionals and loops,
and we'll get to those, but we'll begin with the equivalent of the C language's
<span class="extract"><span class="extract-syntax">return</span></span> statement: ending a function call with some value as an outcome.
Inform calls this "deciding" something, since in Inform programs functions
returning values are usually quite functional: that is, their point is what
value they return, rather than the side-effects of what they did.
</p>

<p class="commentary">Note that returning a value has to invoke the type-checker to ensure that
the return value matches the kind of value expected. This certainly rejects
the phrase if it's used in a definition which isn't meant to be deciding
a value at all, so an "in... only" clause is not needed.
</p>

<p class="commentary">The IF-form of Inform allows the antique syntaxes "yes" and "no" as
synonyms for "decide yes" and "decide no"; these are not present in Basic
Inform, and are defined in the Standard Rules (and only to keep old source
text working).
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Decide</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Control</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Deciding</span><span class="plain-syntax"> </span><span class="identifier-syntax">Outcomes</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">yes</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_yes</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">no</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_no</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">rfalse</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">stop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_stop</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> (</span><span class="identifier-syntax">something</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_decideon</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">return</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">return</span><span class="plain-syntax">-</span><span class="identifier-syntax">value</span><span class="plain-syntax">:</span><span class="identifier-syntax">something</span><span class="plain-syntax">}; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. </b>While "unless" is supposed to be exactly like "if" but with the reversed
sense of the condition, that isn't quite true. For example, there is no
"unless ... then ...": logical it might be, English it is not.
</p>

<p class="commentary">The switch form of "if" is subtly different, and here again "unless" is
not allowed in its place.
</p>

<p class="commentary">As with some other control structures, the definitions here are somewhat
partial, and made up for by direct code in the compiler. (There's a limit to
how much a general syntax for phrases can encode control phrases.)
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-If</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">If</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Unless</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">conditional</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_if</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">c</span><span class="plain-syntax">}  -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">unless</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">conditional</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_unless</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (~~{</span><span class="identifier-syntax">c</span><span class="plain-syntax">})  -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">conditional</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_switch</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (-  -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP24" class="paragraph-anchor"></a><b>&#167;24. </b>"Do nothing" is a curious feature for a high-level programming language (C,
for example, does not have a NOP function); it entered Inform in the earliest
days, when it was useful mainly when natural language syntax had painted users
into a corner. (In the examples, it used to be used when conditions were
awkward to negate &mdash; if condition, do nothing, otherwise blah blah blah &mdash; but
the creation of "unless" made it possible to remove most of the "do
nothing"s.) It is now hardly ever useful.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">do</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nothing</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP25" class="paragraph-anchor"></a><b>&#167;25. </b>After all that, the while loop is simplicity itself. Perhaps the presence
of "unless" for "if" argues for a similarly negated form, "until" for
"while", but users haven't yet petitioned for this.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Loops</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">While</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Repeat</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> - </span><span class="identifier-syntax">condition</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_while</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">while</span><span class="plain-syntax"> {</span><span class="identifier-syntax">c</span><span class="plain-syntax">}  -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP26" class="paragraph-anchor"></a><b>&#167;26. </b>The repeat loop looks like a single construction, but isn't, because the
range can be given in four fundamentally different ways (and the loop variable
then has a different kind of value accordingly). First, the equivalents of
BASIC's <span class="extract"><span class="extract-syntax">for</span></span> loop and of Inform 6's <span class="extract"><span class="extract-syntax">objectloop</span></span>, respectively:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> - </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeat</span><span class="plain-syntax">):</span>
<span class="plain-syntax">        (- </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}={</span><span class="identifier-syntax">v</span><span class="plain-syntax">}: {</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}&lt;={</span><span class="identifier-syntax">w</span><span class="plain-syntax">}: {</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}++)  -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> - </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeat</span><span class="plain-syntax">):</span>
<span class="plain-syntax">        (- </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}={</span><span class="identifier-syntax">v</span><span class="plain-syntax">}: {</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}&lt;={</span><span class="identifier-syntax">w</span><span class="plain-syntax">}: {</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}={-</span><span class="identifier-syntax">next</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}))  -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">OS</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_runthrough</span><span class="plain-syntax">):</span>
<span class="plain-syntax">        (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">repeat</span><span class="plain-syntax">-</span><span class="identifier-syntax">through</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">object</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeatlist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">        (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">repeat</span><span class="plain-syntax">-</span><span class="identifier-syntax">through</span><span class="plain-syntax">-</span><span class="identifier-syntax">list</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP27" class="paragraph-anchor"></a><b>&#167;27. </b>The following are all repeats where the range is the set of rows of a table,
taken in some order, and the repeat variable &mdash; though it does exist &mdash; is
never specified since the relevant row is instead the one selected during
each iteration of the loop.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeattable</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}={</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=1, </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}&lt;=</span><span class="identifier-syntax">TableRows</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}):</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}++, </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2})</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TableRowIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">)==</span><span class="identifier-syntax">false</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                {-</span><span class="identifier-syntax">block</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">order</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeattablereverse</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}={</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=</span><span class="identifier-syntax">TableRows</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}), </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}&gt;=1:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}--, </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2})</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TableRowIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">)==</span><span class="identifier-syntax">false</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                {-</span><span class="identifier-syntax">block</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeattablecol</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}={</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=</span><span class="identifier-syntax">TableNextRow</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">), </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}~=0:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=</span><span class="identifier-syntax">TableNextRow</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}, </span><span class="constant-syntax">1</span><span class="plain-syntax">), </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2})</span>
<span class="plain-syntax">                {-</span><span class="identifier-syntax">block</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_repeattablecolreverse</span><span class="plain-syntax">): (-</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">};</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}={</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=</span><span class="identifier-syntax">TableNextRow</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, -1), </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}~=0:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}=</span><span class="identifier-syntax">TableNextRow</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2}, -1), </span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}, </span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">={-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:2})</span>
<span class="plain-syntax">                {-</span><span class="identifier-syntax">block</span><span class="plain-syntax">}</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}; @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">};</span>
<span class="plain-syntax">    -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP28" class="paragraph-anchor"></a><b>&#167;28. </b>And this loops through the lines of a text file stored internally.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nonexisting</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> - </span><span class="identifier-syntax">internal</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (-</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">for</span><span class="plain-syntax"> ({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1} = </span><span class="identifier-syntax">InternalFileIO_Line</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">F</span><span class="plain-syntax">}): {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1}:</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:1} = </span><span class="identifier-syntax">InternalFileIO_Line</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">loopvar</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">F</span><span class="plain-syntax">}))</span>
<span class="plain-syntax">            {-</span><span class="identifier-syntax">block</span><span class="plain-syntax">}</span>
<span class="plain-syntax">    -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP29" class="paragraph-anchor"></a><b>&#167;29. </b>The equivalent of <span class="extract"><span class="extract-syntax">break</span></span> or <span class="extract"><span class="extract-syntax">continue</span></span> in C or I6, or of <span class="extract"><span class="extract-syntax">last</span></span> or <span class="extract"><span class="extract-syntax">next</span></span>
in Perl. Here "in loop" means "in any of the forms of while or repeat".
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Break</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Loop</span><span class="plain-syntax"> </span><span class="identifier-syntax">Flow</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_break</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">break</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">next</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">loop</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_next</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">continue</span><span class="plain-syntax">; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP30" class="paragraph-anchor"></a><b>&#167;30. </b>The following innocent-looking definition throws a problem message if the
RTP label is not (a) literal text and (b) the leafname of a Markdown file
(once <span class="extract"><span class="extract-syntax">.md</span></span> has been added) in the <span class="extract"><span class="extract-syntax">RTPs</span></span> subdirectory of the current
extension directory: it can only be used from with a directory-format extension.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Run</span><span class="plain-syntax">-</span><span class="identifier-syntax">Time</span><span class="plain-syntax"> </span><span class="identifier-syntax">Problems</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">issue</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">run</span><span class="plain-syntax">-</span><span class="identifier-syntax">time</span><span class="plain-syntax"> </span><span class="identifier-syntax">problem</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pcode</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">({-</span><span class="identifier-syntax">rtp</span><span class="plain-syntax">-</span><span class="identifier-syntax">code</span><span class="plain-syntax">: </span><span class="identifier-syntax">pcode</span><span class="plain-syntax">}, -1, {-</span><span class="identifier-syntax">rtp</span><span class="plain-syntax">-</span><span class="identifier-syntax">location</span><span class="plain-syntax">: </span><span class="identifier-syntax">pcode</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP31" class="paragraph-anchor"></a><b>&#167;31. Values.</b>Some of the things we can do with enumerations, others being listed under
randomness below.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Enumerations</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Values</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Enumerations</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numberof</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">number</span><span class="plain-syntax">-</span><span class="identifier-syntax">of</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">numerical</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numericalvalue</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">X</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">sequence</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sequencenumber</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">indexing</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">X</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">after</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_enumafter</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">next</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">X</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">before</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_enumbefore</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">previous</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">X</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_enumfirst</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">default</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_enumlast</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">before</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">default</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP32" class="paragraph-anchor"></a><b>&#167;32. </b>Random numbers and random items chosen from sets of objects matching a
given description ("a random closed door").
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Randomness</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Randomness</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">random</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randomdesc</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">random</span><span class="plain-syntax">-</span><span class="identifier-syntax">of</span><span class="plain-syntax">} -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">between</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randombetween</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">ranger</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">arithmetic</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randombetween</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">ranger</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">between</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randombetween</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">ranger</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">enumerated</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randombetween</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">ranger</span><span class="plain-syntax">-</span><span class="identifier-syntax">routine</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}({</span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> </span><span class="identifier-syntax">chance</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">M</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">succeeds</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_randomchance</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">GenerateRandomNumber</span><span class="plain-syntax">(1, {</span><span class="identifier-syntax">M</span><span class="plain-syntax">}) &lt;= {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">seed</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax">-</span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">generator</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_seed</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_Seed_RNG</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP33" class="paragraph-anchor"></a><b>&#167;33. </b>A novel feature of Inform is that there is a default value of any kind: for
example, it is 0 for a number, or the empty text for text. When Inform compiles
a value of a given kind but isn't told what value to compile, it always
chooses the default, which is why the following definition works.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-DefaultValues</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Default</span><span class="plain-syntax"> </span><span class="identifier-syntax">Values</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">default</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_defaultvalue</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP34" class="paragraph-anchor"></a><b>&#167;34. Text.</b>Inform programs swim in a sea of texts, and most of the ways to make text
involve substitutions; so phrases to manipulate text are nice to have, but
are bonuses rather than being the essentials.
</p>

<p class="commentary">As repetitive as the following is, it's much simpler and less prone to
possible namespace trouble if we don't define kinds of value for the different
structural levels of text (character, word, punctuated word, etc.).
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Texts</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Text</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Breaking</span><span class="plain-syntax"> </span><span class="identifier-syntax">down</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">characters</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numchars</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">words</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numwords</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">WORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">punctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">words</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numpwords</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">PWORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">unpunctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">words</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numupwords</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">UWORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">lines</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numlines</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">LINE_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraphs</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numparas</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">PARA_BLOB</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">character</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_charnum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_wordnum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">WORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">punctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_pwordnum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">PWORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">unpunctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_upwordnum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">UWORD_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_linenum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">LINE_BLOB</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_paranum</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_GetBlob</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="identifier-syntax">PARA_BLOB</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP35" class="paragraph-anchor"></a><b>&#167;35. </b>The "substituted form of" is a technicality most Inform users never need to
think about; as a one-off phrase, it may as well go here.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">substituted</span><span class="plain-syntax"> </span><span class="identifier-syntax">form</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_subform</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_SubstitutedForm</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP36" class="paragraph-anchor"></a><b>&#167;36. </b>A common matching engine is used for matching plain text...
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-TextReplacement</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Matching</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Replacing</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">exactly</span><span class="plain-syntax"> </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">text</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_exactlymatches</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},0,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">},1) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">text</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_matches</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},0,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">times</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">text</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">), </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nummatches</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},1,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replace</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacewordin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceText</span><span class="plain-syntax">(</span><span class="identifier-syntax">WORD_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">punctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacepwordin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceText</span><span class="plain-syntax">(</span><span class="identifier-syntax">PWORD_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">character</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacechar</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replaceword</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">WORD_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">punctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacepword</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">PWORD_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">unpunctuated</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replaceupword</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">UWORD_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replaceline</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">LINE_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacepara</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_ReplaceBlob</span><span class="plain-syntax">(</span><span class="identifier-syntax">PARA_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">match</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_textfirstindex</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">match0_idx2</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) * (</span><span class="identifier-syntax">match0_idx</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">match</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_textlastindex</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">match0_idx2</span><span class="plain-syntax"> -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">length</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">match</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_textlength</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">match0_idx2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">match0_idx</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP37" class="paragraph-anchor"></a><b>&#167;37. </b>...and for regular expressions, though here we also have access to the
exact text which matched (not interesting in the plain text case since it's
the same as the search text, up to case at least), and the values of matched
subexpressions (which the plain text case doesn't have).
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-RegExp</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">Expressions</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">exactly</span><span class="plain-syntax"> </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">expression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_exactlymatchesre</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">REGEXP_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},0,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">},1) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">expression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_matchesre</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">REGEXP_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},0,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">matching</span><span class="plain-syntax"> </span><span class="identifier-syntax">regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">expression</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_matchtext</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_RE_GetMatchVar</span><span class="plain-syntax">(0) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">matching</span><span class="plain-syntax"> </span><span class="identifier-syntax">subexpression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_subexpressiontext</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_RE_GetMatchVar</span><span class="plain-syntax">({</span><span class="identifier-syntax">N</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">first</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">subexpression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_refirstindex</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA2</span><span class="plain-syntax"> ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) * (</span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA1</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">subexpression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_relastindex</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ((</span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) * </span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA2</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">length</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">subexpression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_relength</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">RE_Subexpressions</span><span class="plain-syntax">--&gt;{</span><span class="identifier-syntax">n</span><span class="plain-syntax">}--&gt;</span><span class="identifier-syntax">RE_DATA1</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">times</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">expression</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">),</span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nummatchesre</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">REGEXP_BLOB</span><span class="plain-syntax">,{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},1,{</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">replace</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">regular</span><span class="plain-syntax"> </span><span class="identifier-syntax">expression</span><span class="plain-syntax"> (</span><span class="identifier-syntax">find</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">replace</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">), </span><span class="identifier-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">insensitively</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_replacere</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_Replace_RE</span><span class="plain-syntax">(</span><span class="identifier-syntax">REGEXP_BLOB</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">find</span><span class="plain-syntax">},</span>
<span class="plain-syntax">        {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">replace</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP38" class="paragraph-anchor"></a><b>&#167;38. </b>Casing of text.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-TextCasing</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Casing</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Text</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">lower</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_lowercase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersToCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">upper</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_uppercase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersToCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">title</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_titlecase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersToCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">2</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">sentence</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sentencecase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersToCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">text</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">3</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">lower</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_inlower</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersOfCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">upper</span><span class="plain-syntax"> </span><span class="identifier-syntax">case</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_inupper</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TEXT_TY_CharactersOfCase</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP39" class="paragraph-anchor"></a><b>&#167;39. Adaptive text.</b>See test case <span class="extract"><span class="extract-syntax">BIP-AdaptiveText</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Adaptive</span><span class="plain-syntax"> </span><span class="identifier-syntax">Text</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">infinitive</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_infinitive</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(1); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">past</span><span class="plain-syntax"> </span><span class="identifier-syntax">participle</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_pastpart</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(2); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">present</span><span class="plain-syntax"> </span><span class="identifier-syntax">participle</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_prespart</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(3); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">adapt</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_adapt</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_POS</span><span class="plain-syntax">, </span><span class="identifier-syntax">PNToVP</span><span class="plain-syntax">(), </span><span class="identifier-syntax">story_tense</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">adapt</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">grammatical</span><span class="plain-syntax"> </span><span class="identifier-syntax">tense</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_adaptt</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_POS</span><span class="plain-syntax">, </span><span class="identifier-syntax">PNToVP</span><span class="plain-syntax">(), {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">adapt</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">narrative</span><span class="plain-syntax"> </span><span class="identifier-syntax">viewpoint</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_adaptv</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_POS</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, </span><span class="identifier-syntax">story_tense</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">adapt</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">grammatical</span><span class="plain-syntax"> </span><span class="identifier-syntax">tense</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">narrative</span><span class="plain-syntax"> </span><span class="identifier-syntax">viewpoint</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_adaptvt</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_POS</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">negate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_negate</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_NEG</span><span class="plain-syntax">, </span><span class="identifier-syntax">PNToVP</span><span class="plain-syntax">(), </span><span class="identifier-syntax">story_tense</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">negate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">grammatical</span><span class="plain-syntax"> </span><span class="identifier-syntax">tense</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_negatet</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_NEG</span><span class="plain-syntax">, </span><span class="identifier-syntax">PNToVP</span><span class="plain-syntax">(), {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">negate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">narrative</span><span class="plain-syntax"> </span><span class="identifier-syntax">viewpoint</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_negatev</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_NEG</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, </span><span class="identifier-syntax">story_tense</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">negate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">verb</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">grammatical</span><span class="plain-syntax"> </span><span class="identifier-syntax">tense</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">narrative</span><span class="plain-syntax"> </span><span class="identifier-syntax">viewpoint</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_negatevt</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_NEG</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">meaning</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">verb</span><span class="plain-syntax">): (- {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}(</span><span class="identifier-syntax">CV_MEANING</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP40" class="paragraph-anchor"></a><b>&#167;40. Data Structures.</b>Inform provides three main data structures: tables, lists, and relations,
which we will take in that order.
</p>

<p class="commentary">Tables mimic tables of data as seen in books or scientific papers. Note that
changing a table entry is not something defined here as a phrase: the
ever-powerful "now" can do that. But changing something to a non-value &mdash;
or "blanking" it &mdash; requires specialist phrases.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Tables</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Data</span><span class="plain-syntax"> </span><span class="identifier-syntax">Structures</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Tables</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">choose</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">/</span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">row</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_chooserow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">} = {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}; {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">} = {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">choose</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">/</span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">row</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">valued</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">w</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_chooserowwith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">} = {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}; {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">} = </span><span class="identifier-syntax">TableRowCorr</span><span class="plain-syntax">(</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">w</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">choose</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">/</span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_chooseblankrow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">} = {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}; {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">} = </span><span class="identifier-syntax">TableBlankRow</span><span class="plain-syntax">(</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">choose</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">/</span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">random</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_chooserandomrow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">} = {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}; {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">} = </span><span class="identifier-syntax">TableRandomRow</span><span class="plain-syntax">(</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">rows</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numrows</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableRows</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">rows</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numblank</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableBlankRows</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> </span><span class="identifier-syntax">rows</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numfilled</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableFilledRows</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">there</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TR</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_thereis</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">-</span><span class="identifier-syntax">exists</span><span class="plain-syntax">:</span><span class="identifier-syntax">TR</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">there</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">no</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TR</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_thereisno</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- ({-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">-</span><span class="identifier-syntax">exists</span><span class="plain-syntax">:</span><span class="identifier-syntax">TR</span><span class="plain-syntax">} == </span><span class="identifier-syntax">false</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tr</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_blankout</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">-</span><span class="identifier-syntax">blank</span><span class="plain-syntax">-</span><span class="identifier-syntax">out</span><span class="plain-syntax">:</span><span class="identifier-syntax">tr</span><span class="plain-syntax">}; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">whole</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_blankoutrow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableBlankOutRow</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">whole</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax">/</span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_blankoutcol</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableBlankOutColumn</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">blank</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">whole</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_blankouttable</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableBlankOutAll</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP41" class="paragraph-anchor"></a><b>&#167;41. </b>These four are for debugging purposes only, and are used in the same test
case. "Showme the contents of ..." is not a text substitution, for efficiency
reasons: for a large table it could produce a gargantuan output, and in a
story file with memory constraints, one might not want to store that in a
text variable.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">showme</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">contents</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_showmetable</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableDebug</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">current</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_currenttablerow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableRowDebug</span><span class="plain-syntax">({-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_0</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">my</span><span class="plain-syntax">:</span><span class="identifier-syntax">ct_1</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_tablerow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableRowDebug</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_tablecolumn</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableColumnDebug</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP42" class="paragraph-anchor"></a><b>&#167;42. </b>Sorting.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-TableSort</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Sorting</span><span class="plain-syntax"> </span><span class="identifier-syntax">Tables</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortrandom</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableShuffle</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortcolumn</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableSort</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_ASCENDING</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TC</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">column</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortcolumnreverse</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableSort</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">TC</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_DESCENDING</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cf</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">number</span><span class="plain-syntax">, </span><span class="identifier-syntax">number</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sorttablephrase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">TableSort</span><span class="plain-syntax">({</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">SORT_ASCENDING</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, {</span><span class="identifier-syntax">cf</span><span class="plain-syntax">}--&gt;1); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP43" class="paragraph-anchor"></a><b>&#167;43. Lists.</b>The following are all for adding and removing values to dynamic lists.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Lists</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Lists</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">add</span><span class="plain-syntax"> (</span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_addtolist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">add</span><span class="plain-syntax"> (</span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_addatentry</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">, {</span><span class="identifier-syntax">E</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">add</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LX</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">absent</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_addlisttolist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_AppendList</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">LX</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">add</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LX</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax">) </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_addlistatentry</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_AppendList</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">LX</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">, {</span><span class="identifier-syntax">E</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove</span><span class="plain-syntax"> (</span><span class="identifier-syntax">existing</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">present</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_remfromlist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_RemoveValue</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">existing</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">present</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_remlistfromlist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Remove_List</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">entry</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">present</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rementry</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_RemoveItemRange</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">remove</span><span class="plain-syntax"> </span><span class="identifier-syntax">entries</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">), </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">present</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rementries</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_RemoveItemRange</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N2</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">options</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP44" class="paragraph-anchor"></a><b>&#167;44. </b>Searching a list is implemented in a somewhat crude way at present, and the
following syntax may later be replaced with a suitable verb "to be listed
in", so that there's no need to imitate.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">listed</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_islistedin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">LIST_OF_TY_FindItem</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">})) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">listed</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_isnotlistedin</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">LIST_OF_TY_FindItem</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}) == </span><span class="identifier-syntax">false</span><span class="plain-syntax">) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP45" class="paragraph-anchor"></a><b>&#167;45. </b>A description is a representation of a set of objects by means of a
predicate (e.g., "open unlocked doors"), and it converts into a list of
current members (in creation order), but there's no reverse process.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_listofdesc</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">-</span><span class="identifier-syntax">list</span><span class="plain-syntax">-</span><span class="identifier-syntax">of</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">} -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP46" class="paragraph-anchor"></a><b>&#167;46. </b>Determining and setting the length:
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-ListLength</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Length</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">lists</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">entries</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">of</span><span class="plain-syntax">/</span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numberentries</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_GetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">truncate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">entries</span><span class="plain-syntax">/</span><span class="identifier-syntax">entry</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_truncate</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, -1, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">truncate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">first</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">entries</span><span class="plain-syntax">/</span><span class="identifier-syntax">entry</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_truncatefirst</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, -1, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">truncate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">last</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">entries</span><span class="plain-syntax">/</span><span class="identifier-syntax">entry</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_truncatelast</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, -1, -1); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">extend</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">entries</span><span class="plain-syntax">/</span><span class="identifier-syntax">entry</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_extend</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">change</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">have</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">entries</span><span class="plain-syntax">/</span><span class="identifier-syntax">entry</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_changelength</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">N</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP47" class="paragraph-anchor"></a><b>&#167;47. </b>Easy but useful list operations. Sorting ultimately uses a common sorting
mechanism, in "Sort.i6t", which handles both lists and tables.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-ListOperations</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">List</span><span class="plain-syntax"> </span><span class="identifier-syntax">operations</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_reverselist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Reverse</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">rotate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rotatelist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Rotate</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">rotate</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">backwards</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rotatelistback</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Rotate</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="constant-syntax">1</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_ASCENDING</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlistreverse</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_DESCENDING</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cf</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">number</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlistphrase</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_ASCENDING</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, {</span><span class="identifier-syntax">cf</span><span class="plain-syntax">}--&gt;1); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">random</span><span class="plain-syntax"> </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlistrandom</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_LIST_RANDOM</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">property</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlistproperty</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_ASCENDING</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">property</span><span class="plain-syntax">-</span><span class="identifier-syntax">holds</span><span class="plain-syntax">-</span><span class="identifier-syntax">block</span><span class="plain-syntax">-</span><span class="identifier-syntax">value</span><span class="plain-syntax">:</span><span class="identifier-syntax">P</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">sort</span><span class="plain-syntax"> (</span><span class="identifier-syntax">L</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">) </span><span class="identifier-syntax">in</span><span class="plain-syntax">/</span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> - </span><span class="identifier-syntax">property</span><span class="plain-syntax">) </span><span class="identifier-syntax">order</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_sortlistpropertyreverse</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">LIST_OF_TY_Sort</span><span class="plain-syntax">({-</span><span class="identifier-syntax">lvalue</span><span class="plain-syntax">-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">SORT_DESCENDING</span><span class="plain-syntax">, {</span><span class="identifier-syntax">P</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">property</span><span class="plain-syntax">-</span><span class="identifier-syntax">holds</span><span class="plain-syntax">-</span><span class="identifier-syntax">block</span><span class="plain-syntax">-</span><span class="identifier-syntax">value</span><span class="plain-syntax">:</span><span class="identifier-syntax">P</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP48" class="paragraph-anchor"></a><b>&#167;48. </b>Relations are the final data structure given here. In some ways they are
the most fundamental of all, but they're not either set or tested by
procedural phrases &mdash; they lie in the linguistic structure of conditions.
So all we have here are the route-finding phrases:
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Relations</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Relations</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">show</span><span class="plain-syntax"> </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_showrelation</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">show</span><span class="plain-syntax">-</span><span class="identifier-syntax">me</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}; </span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">object</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">next</span><span class="plain-syntax"> </span><span class="identifier-syntax">step</span><span class="plain-syntax"> </span><span class="identifier-syntax">via</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nextstep</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RelationRouteTo</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">},{</span><span class="identifier-syntax">O1</span><span class="plain-syntax">},{</span><span class="identifier-syntax">O2</span><span class="plain-syntax">},</span><span class="identifier-syntax">false</span><span class="plain-syntax">) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">steps</span><span class="plain-syntax"> </span><span class="identifier-syntax">via</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">objects</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">O2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">object</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_numbersteps</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RelationRouteTo</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">},{</span><span class="identifier-syntax">O1</span><span class="plain-syntax">},{</span><span class="identifier-syntax">O2</span><span class="plain-syntax">},</span><span class="identifier-syntax">true</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_leftdomain</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">left</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightdomain</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">) -). [1]</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightdomain</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">) -). [2]</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">who</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">relate</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_leftlookuplist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">left</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">, {</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">}) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightlookuplist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">, {</span><span class="identifier-syntax">X</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">}) -). [1]</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightlookuplist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">, {</span><span class="identifier-syntax">X</span><span class="plain-syntax">}, {-</span><span class="identifier-syntax">new</span><span class="plain-syntax">:</span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">}) -). [2]</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_ifright</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">left</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">, {</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_ifleft</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">, {</span><span class="identifier-syntax">X</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">who</span><span class="plain-syntax"> </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_leftlookup</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">left</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">, {</span><span class="identifier-syntax">Y</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax">) -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightlookup</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">, {</span><span class="identifier-syntax">X</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">) -). [1]</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">that</span><span class="plain-syntax">/</span><span class="identifier-syntax">which</span><span class="plain-syntax">/</span><span class="identifier-syntax">whom</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">relates</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">R</span><span class="plain-syntax"> - </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rightlookup</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">match</span><span class="plain-syntax">-</span><span class="identifier-syntax">right</span><span class="plain-syntax">-</span><span class="identifier-syntax">relation</span><span class="plain-syntax">-</span><span class="identifier-syntax">domain</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}</span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax">({-</span><span class="identifier-syntax">by</span><span class="plain-syntax">-</span><span class="identifier-syntax">reference</span><span class="plain-syntax">:</span><span class="identifier-syntax">R</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">, {</span><span class="identifier-syntax">X</span><span class="plain-syntax">}, </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">) -). [2]</span>
</pre>
<p class="commentary firstcommentary"><a id="SP49" class="paragraph-anchor"></a><b>&#167;49. Functional Programming.</b>Here we have the ability to use the name of a function as a value, and to
apply such a function.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Apply</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">7</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Functional</span><span class="plain-syntax"> </span><span class="identifier-syntax">Programming</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Applying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Functions</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> (</span><span class="identifier-syntax">desc</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_valuematch</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">description</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">applied</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_applied0</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_applied1</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">M</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">M</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_applied2</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">M</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">third</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">M</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_applied3</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">} -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">apply</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_apply0</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">}; -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">apply</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_apply1</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">}; -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">apply</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_apply2</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">}; -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">apply</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">M</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax"> (</span><span class="identifier-syntax">third</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax"> - </span><span class="identifier-syntax">M</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_apply3</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- {-</span><span class="identifier-syntax">primitive</span><span class="plain-syntax">-</span><span class="identifier-syntax">definition</span><span class="plain-syntax">:</span><span class="identifier-syntax">function</span><span class="plain-syntax">-</span><span class="identifier-syntax">application</span><span class="plain-syntax">}; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP50" class="paragraph-anchor"></a><b>&#167;50. </b>The standard map, reduce and filter operations found in most functional
programming languages also have Inform analogues.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Map</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Working</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">Lists</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">original</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_appliedlist</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">result</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ls</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">original</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">mapped</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">add</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">mapped</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">result</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">result</span><span class="plain-syntax">.</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">function</span><span class="plain-syntax"> - </span><span class="identifier-syntax">phrase</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">) -&gt; </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">reduction</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">original</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_reduction</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">original</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">increase</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">now</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">otherwise</span><span class="plain-syntax"> </span><span class="identifier-syntax">now</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">function</span><span class="plain-syntax"> </span><span class="identifier-syntax">applied</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">total</span><span class="plain-syntax">.</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">filter</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">criterion</span><span class="plain-syntax"> - </span><span class="identifier-syntax">description</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Ks</span><span class="plain-syntax">) </span><span class="identifier-syntax">of</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">full</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> - </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">values</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_filter</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">filtered</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">repeat</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">through</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">full</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">matches</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">criterion</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">add</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">item</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">filtered</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">filtered</span><span class="plain-syntax"> </span><span class="identifier-syntax">list</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP51" class="paragraph-anchor"></a><b>&#167;51. Rulebooks and Activities.</b>Firing off activities:
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Activities</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">8</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Rulebooks</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Activities</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Carrying</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">Activities</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">carry</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_carryout</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">CarryOutActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">carry</span><span class="plain-syntax"> </span><span class="identifier-syntax">out</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_carryoutwith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">CarryOutActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">val</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">continue</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_continueactivity</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">rfalse</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP52" class="paragraph-anchor"></a><b>&#167;52. </b>Advanced activity phrases: for setting up one's own activities structured
around I7 source text. People tend not to use this much, and perhaps that's
a good thing, but it does open up possibilities, and it's good for
retro-fitting onto extensions to make them more customisable.
</p>

<p class="commentary">These are really only useful in an activity-rich environment, in any case.
See the documentation example <span class="extract"><span class="extract-syntax">AntSensitiveSunglasses</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Advanced</span><span class="plain-syntax"> </span><span class="identifier-syntax">Activities</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_beginactivity</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">BeginActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">begin</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_beginactivitywith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">BeginActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">val</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> </span><span class="identifier-syntax">handling</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_handlingactivity</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (~~(</span><span class="identifier-syntax">ForActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}))) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">whether</span><span class="plain-syntax"> </span><span class="identifier-syntax">handling</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_handlingactivitywith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (~~(</span><span class="identifier-syntax">ForActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">val</span><span class="plain-syntax">}))) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_endactivity</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">EndActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_endactivitywith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">EndActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">val</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">abandon</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_abandonactivity</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">AbandonActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">abandon</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> - </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">activity</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_abandonactivitywith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">AbandonActivity</span><span class="plain-syntax">({</span><span class="identifier-syntax">A</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">val</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP53" class="paragraph-anchor"></a><b>&#167;53. </b>Here are four different ways to invoke a rule or rulebook:
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Rules</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Following</span><span class="plain-syntax"> </span><span class="identifier-syntax">Rules</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">follow</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_follow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">follow</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">producing</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_followfor</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}, </span><span class="identifier-syntax">true</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">follow</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_follow</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">produced</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">producing</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_producedby</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">ResultOfRule</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">true</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">strong</span><span class="plain-syntax">-</span><span class="identifier-syntax">kind</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">produced</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">producing</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_producedbyfor</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">ResultOfRule</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}, </span><span class="identifier-syntax">true</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">strong</span><span class="plain-syntax">-</span><span class="identifier-syntax">kind</span><span class="plain-syntax">:</span><span class="identifier-syntax">L</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><span class="identifier-syntax">produced</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">producing</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_producedby</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">ResultOfRule</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">true</span><span class="plain-syntax">, {-</span><span class="identifier-syntax">strong</span><span class="plain-syntax">-</span><span class="identifier-syntax">kind</span><span class="plain-syntax">:</span><span class="identifier-syntax">K</span><span class="plain-syntax">}) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">abide</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_abide</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">})) </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">abide</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">producing</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">) </span><span class="identifier-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax"> - </span><span class="identifier-syntax">K</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_abidefor</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">V</span><span class="plain-syntax">}, </span><span class="identifier-syntax">true</span><span class="plain-syntax">)) </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">abide</span><span class="plain-syntax"> </span><span class="identifier-syntax">by</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RL</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax"> </span><span class="identifier-syntax">based</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_abide</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FollowRulebook</span><span class="plain-syntax">({</span><span class="identifier-syntax">RL</span><span class="plain-syntax">})) </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP54" class="paragraph-anchor"></a><b>&#167;54. </b>Rules return <span class="extract"><span class="extract-syntax">true</span></span> to indicate a decision, which could be either a success
or a failure, and optionally may also return a value. If they return <span class="extract"><span class="extract-syntax">false</span></span>,
there's no decision.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Rules</span></span> once again.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Success</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Failure</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">make</span><span class="plain-syntax"> </span><span class="identifier-syntax">no</span><span class="plain-syntax"> </span><span class="identifier-syntax">decision</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_nodecision</span><span class="plain-syntax">): (- </span><span class="identifier-syntax">rfalse</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">succeeds</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_succeeds</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RulebookSucceeds</span><span class="plain-syntax">(); </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">fails</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_fails</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RulebookFails</span><span class="plain-syntax">(); </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">succeeds</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">result</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_succeedswith</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">RulebookSucceeds</span><span class="plain-syntax">({-</span><span class="identifier-syntax">strong</span><span class="plain-syntax">-</span><span class="identifier-syntax">kind</span><span class="plain-syntax">:</span><span class="identifier-syntax">rule</span><span class="plain-syntax">-</span><span class="identifier-syntax">return</span><span class="plain-syntax">-</span><span class="identifier-syntax">kind</span><span class="plain-syntax">},{-</span><span class="identifier-syntax">return</span><span class="plain-syntax">-</span><span class="identifier-syntax">value</span><span class="plain-syntax">-</span><span class="identifier-syntax">from</span><span class="plain-syntax">-</span><span class="identifier-syntax">rule</span><span class="plain-syntax">:</span><span class="identifier-syntax">val</span><span class="plain-syntax">}); </span><span class="identifier-syntax">rtrue</span><span class="plain-syntax">; -) - </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">succeeded</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_succeeded</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">RulebookSucceeded</span><span class="plain-syntax">()) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax"> </span><span class="identifier-syntax">failed</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_failed</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">RulebookFailed</span><span class="plain-syntax">()) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">rulebook</span><span class="plain-syntax"> </span><span class="identifier-syntax">outcome</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">outcome</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">rulebook</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_rulebookoutcome</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">ResultOfRule</span><span class="plain-syntax">()) -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP55" class="paragraph-anchor"></a><b>&#167;55. Basic IO.</b>Basic input/output phrases, that mostly used to be in the Basic Screen Effects extension.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">9</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">Input</span><span class="plain-syntax">/</span><span class="identifier-syntax">Output</span>
</pre>
<p class="commentary firstcommentary"><a id="SP56" class="paragraph-anchor"></a><b>&#167;56. </b>Some basic visual effects, which may or may not be rendered the way the user
hopes: that's partly up to the virtual machine, unfortunately.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-SayFonts</span></span>, though since <span class="extract"><span class="extract-syntax">intest</span></span> runs on plain text only,
you may need to run this in the Inform application to be convinced.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Saying</span><span class="plain-syntax"> </span><span class="identifier-syntax">Fonts</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Visual</span><span class="plain-syntax"> </span><span class="identifier-syntax">Effects</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">bold</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_bold</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">style</span><span class="plain-syntax"> </span><span class="identifier-syntax">bold</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">italic</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_italic</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">style</span><span class="plain-syntax"> </span><span class="identifier-syntax">underline</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">roman</span><span class="plain-syntax"> </span><span class="identifier-syntax">type</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_roman</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">style</span><span class="plain-syntax"> </span><span class="identifier-syntax">roman</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">fixed</span><span class="plain-syntax"> </span><span class="identifier-syntax">letter</span><span class="plain-syntax"> </span><span class="identifier-syntax">spacing</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_fixedspacing</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">font</span><span class="plain-syntax"> </span><span class="identifier-syntax">off</span><span class="plain-syntax">; -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax"> </span><span class="identifier-syntax">letter</span><span class="plain-syntax"> </span><span class="identifier-syntax">spacing</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">phs_varspacing</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">font</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax">; -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">mode</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetReverseMode</span><span class="plain-syntax">(1); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">reverse</span><span class="plain-syntax"> </span><span class="identifier-syntax">mode</span><span class="plain-syntax"> </span><span class="identifier-syntax">off</span><span class="plain-syntax"> -- </span><span class="identifier-syntax">running</span><span class="plain-syntax"> </span><span class="identifier-syntax">on</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetReverseMode</span><span class="plain-syntax">(0); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP57" class="paragraph-anchor"></a><b>&#167;57. </b>Basic colours are supported in both architectures, but RGB colours are only
supported in Glulx.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">Colours</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">foreground</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">colour</span><span class="plain-syntax">/</span><span class="identifier-syntax">color</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">({</span><span class="identifier-syntax">C</span><span class="plain-syntax">}, </span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">) </span><span class="identifier-syntax">letters</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">({</span><span class="identifier-syntax">C</span><span class="plain-syntax">}, </span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">background</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">/</span><span class="identifier-syntax">color</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">(</span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">, {</span><span class="identifier-syntax">C</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">reset</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">screen</span><span class="plain-syntax">/</span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">colours</span><span class="plain-syntax">/</span><span class="identifier-syntax">colors</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">(</span><span class="identifier-syntax">BASIC_COLOUR_DEFAULT</span><span class="plain-syntax">, </span><span class="identifier-syntax">BASIC_COLOUR_DEFAULT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">default</span><span class="plain-syntax"> </span><span class="identifier-syntax">colours</span><span class="plain-syntax">/</span><span class="identifier-syntax">colors</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">(</span><span class="identifier-syntax">BASIC_COLOUR_DEFAULT</span><span class="plain-syntax">, </span><span class="identifier-syntax">BASIC_COLOUR_DEFAULT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">Colours</span><span class="plain-syntax"> (</span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Glulx</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax">.</span>
<span class="plain-syntax">#&lt;</span><span class="identifier-syntax">red</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax">&gt;&lt;</span><span class="identifier-syntax">green</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax">&gt;&lt;</span><span class="identifier-syntax">blue</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax">&gt; </span><span class="identifier-syntax">specifies</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> </span><span class="identifier-syntax">parts</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">red</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax"> (2 </span><span class="identifier-syntax">hexadecimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digits</span><span class="plain-syntax">),</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">green</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax"> (2 </span><span class="identifier-syntax">hexadecimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digits</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">blue</span><span class="plain-syntax"> </span><span class="identifier-syntax">level</span><span class="plain-syntax"> (2 </span><span class="identifier-syntax">hexadecimal</span><span class="plain-syntax"> </span><span class="identifier-syntax">digits</span><span class="plain-syntax">).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">foreground</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">colour</span><span class="plain-syntax">/</span><span class="identifier-syntax">color</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">({</span><span class="identifier-syntax">C</span><span class="plain-syntax">}, </span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">) </span><span class="identifier-syntax">letters</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">({</span><span class="identifier-syntax">C</span><span class="plain-syntax">}, </span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">background</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">/</span><span class="identifier-syntax">color</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax"> - </span><span class="identifier-syntax">RGB</span><span class="plain-syntax"> </span><span class="identifier-syntax">colour</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_SetWindowColours</span><span class="plain-syntax">(</span><span class="identifier-syntax">BASIC_COLOUR_CURRENT</span><span class="plain-syntax">, {</span><span class="identifier-syntax">C</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP58" class="paragraph-anchor"></a><b>&#167;58. </b>Some basic window phrases, which are supported by both the Z-Machine and Glulx.
(See the Glk Foundations for Glk-specific phrases.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Basic</span><span class="plain-syntax"> </span><span class="identifier-syntax">Window</span><span class="plain-syntax"> </span><span class="identifier-syntax">Effects</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">clear</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">screen</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ClearScreen</span><span class="plain-syntax">(0); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">clear</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">main</span><span class="plain-syntax"> </span><span class="identifier-syntax">screen</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ClearScreen</span><span class="plain-syntax">(2); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">clear</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ClearScreen</span><span class="plain-syntax">(1); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">screen</span><span class="plain-syntax"> </span><span class="identifier-syntax">height</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ScreenHeight</span><span class="plain-syntax">() -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">screen</span><span class="plain-syntax"> </span><span class="identifier-syntax">width</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ScreenWidth</span><span class="plain-syntax">() -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP59" class="paragraph-anchor"></a><b>&#167;59. </b>Pausing the game.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Pausing</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">game</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">Exclude</span><span class="plain-syntax"> </span><span class="identifier-syntax">navigation</span><span class="plain-syntax"> </span><span class="identifier-syntax">keys</span><span class="plain-syntax"> ]</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">wait</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">any</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">while</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">next</span><span class="plain-syntax"> </span><span class="identifier-syntax">pressed</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">down</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">page</span><span class="plain-syntax"> </span><span class="identifier-syntax">down</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">page</span><span class="plain-syntax"> </span><span class="identifier-syntax">up</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">up</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+003</span><span class="identifier-syntax">F</span><span class="plain-syntax"> [?, </span><span class="identifier-syntax">which</span><span class="plain-syntax"> </span><span class="identifier-syntax">might</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">used</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax"> </span><span class="identifier-syntax">unknown</span><span class="plain-syntax"> </span><span class="identifier-syntax">character</span><span class="plain-syntax">]:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">otherwise</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">break</span><span class="plain-syntax">;</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">Technically</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">space</span><span class="plain-syntax"> </span><span class="identifier-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> ]</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">wait</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">SPACE</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">/</span><span class="identifier-syntax">bar</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">while</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">next</span><span class="plain-syntax"> </span><span class="identifier-syntax">pressed</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+0020 [</span><span class="identifier-syntax">space</span><span class="plain-syntax">]:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            -- </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">break</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">pause</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">game</span><span class="plain-syntax">/</span><span class="identifier-syntax">story</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">say</span><span class="plain-syntax"> "[</span><span class="identifier-syntax">paragraph</span><span class="plain-syntax"> </span><span class="identifier-syntax">break</span><span class="plain-syntax">]</span><span class="identifier-syntax">Please</span><span class="plain-syntax"> </span><span class="identifier-syntax">press</span><span class="plain-syntax"> </span><span class="identifier-syntax">SPACE</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">continue</span><span class="plain-syntax">.";</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wait</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">space</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">clear</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">screen</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">stop</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">game</span><span class="plain-syntax">/</span><span class="identifier-syntax">story</span><span class="plain-syntax"> </span><span class="identifier-syntax">abruptly</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">quit</span><span class="plain-syntax">; -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">show</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">current</span><span class="plain-syntax"> </span><span class="identifier-syntax">quotation</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">ClearBoxedText</span><span class="plain-syntax">(); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP60" class="paragraph-anchor"></a><b>&#167;60. </b>Keyboard input phrases.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Keyboard</span><span class="plain-syntax"> </span><span class="identifier-syntax">Input</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">character</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">code</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">next</span><span class="plain-syntax"> </span><span class="identifier-syntax">pressed</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_KeyChar</span><span class="plain-syntax">() -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">prompt</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">enter</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">line</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_ReadKeyboard</span><span class="plain-syntax">(</span><span class="identifier-syntax">buffer2</span><span class="plain-syntax">); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">player</span><span class="plain-syntax">'</span><span class="identifier-syntax">s</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">input</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_PrintBuffer</span><span class="plain-syntax">(</span><span class="identifier-syntax">buffer2</span><span class="plain-syntax">); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP61" class="paragraph-anchor"></a><b>&#167;61. </b>Function keys.
Keyboard function keys are defined as unicode character constants. A mix of
actual control codes, unicode characters which kind of represent the keys, and
private use area codes.
</p>

<pre class="displayed-code all-displayed-code code-font">

<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">delete</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+0008. [</span><span class="identifier-syntax">Both</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">Machine</span><span class="plain-syntax"> </span><span class="identifier-syntax">and</span><span class="plain-syntax"> </span><span class="identifier-syntax">Glulx</span><span class="plain-syntax"> </span><span class="identifier-syntax">standards</span><span class="plain-syntax"> </span><span class="identifier-syntax">call</span><span class="plain-syntax"> </span><span class="identifier-syntax">it</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">delete</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax">, </span><span class="identifier-syntax">even</span><span class="plain-syntax"> </span><span class="identifier-syntax">though</span><span class="plain-syntax"> </span><span class="identifier-syntax">backspace</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">perhaps</span><span class="plain-syntax"> </span><span class="identifier-syntax">more</span><span class="plain-syntax"> </span><span class="identifier-syntax">accurate</span><span class="plain-syntax">.]</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">down</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+2193.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">end</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+21</span><span class="identifier-syntax">F2</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">escape</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+001</span><span class="identifier-syntax">B</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f1</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF01</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f2</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF02</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f3</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF03</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f4</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF04</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f5</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF05</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f6</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF06</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f7</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF07</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f8</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF08</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f9</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF09</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f10</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF0A</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f11</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF0B</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">f12</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">EF0C</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">home</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+21</span><span class="identifier-syntax">F1</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">left</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+2190.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">page</span><span class="plain-syntax"> </span><span class="identifier-syntax">down</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+21</span><span class="identifier-syntax">DF</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">page</span><span class="plain-syntax"> </span><span class="identifier-syntax">up</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+21</span><span class="identifier-syntax">DE</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+000</span><span class="identifier-syntax">A</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">right</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+2192.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">tab</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+0009.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">unknown</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+</span><span class="identifier-syntax">FFFD</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">up</span><span class="plain-syntax"> </span><span class="identifier-syntax">key</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">always</span><span class="plain-syntax"> </span><span class="identifier-syntax">unicode</span><span class="plain-syntax"> </span><span class="identifier-syntax">U</span><span class="plain-syntax">+2191.</span>
</pre>
<p class="commentary firstcommentary"><a id="SP62" class="paragraph-anchor"></a><b>&#167;62. </b>Customising the status line.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">7</span><span class="plain-syntax"> - </span><span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">Status</span><span class="plain-syntax"> </span><span class="identifier-syntax">Window</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">redraw</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">bar</span><span class="plain-syntax">/</span><span class="identifier-syntax">line</span><span class="plain-syntax">/</span><span class="identifier-syntax">window</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">DrawStatusLine</span><span class="plain-syntax">(); -).</span>

<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax">-</span><span class="identifier-syntax">name</span><span class="plain-syntax"> </span><span class="identifier-syntax">that</span><span class="plain-syntax"> </span><span class="identifier-syntax">varies</span><span class="plain-syntax">.</span>
<span class="identifier-syntax">The</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">variable</span><span class="plain-syntax"> </span><span class="identifier-syntax">translates</span><span class="plain-syntax"> </span><span class="identifier-syntax">into</span><span class="plain-syntax"> </span><span class="identifier-syntax">Inter</span><span class="plain-syntax"> </span><span class="identifier-syntax">as</span><span class="plain-syntax"> "</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">".</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">fill</span><span class="plain-syntax">/</span><span class="identifier-syntax">redraw</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">bar</span><span class="plain-syntax">/</span><span class="identifier-syntax">line</span><span class="plain-syntax">/</span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">with</span><span class="plain-syntax"> (</span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax">-</span><span class="identifier-syntax">name</span><span class="plain-syntax">), </span><span class="identifier-syntax">once</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">old</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">now</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">new</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">redraw</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">once</span><span class="plain-syntax"> </span><span class="identifier-syntax">only</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">now</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">old</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">table</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">move</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">bar</span><span class="plain-syntax">/</span><span class="identifier-syntax">line</span><span class="plain-syntax">/</span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">cursor</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax"> (</span><span class="identifier-syntax">row</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">and</span><span class="plain-syntax">/-- </span><span class="identifier-syntax">column</span><span class="plain-syntax">/</span><span class="identifier-syntax">col</span><span class="plain-syntax"> (</span><span class="identifier-syntax">col</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_MoveCursorInStatusLine</span><span class="plain-syntax">({</span><span class="identifier-syntax">row</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">col</span><span class="plain-syntax">}); -).</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">status</span><span class="plain-syntax"> </span><span class="identifier-syntax">bar</span><span class="plain-syntax">/</span><span class="identifier-syntax">line</span><span class="plain-syntax">/</span><span class="identifier-syntax">window</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rows</span><span class="plain-syntax"> - </span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">row</span><span class="plain-syntax">/</span><span class="identifier-syntax">rows</span><span class="plain-syntax">:</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">VM_StatusLineHeight</span><span class="plain-syntax">({</span><span class="identifier-syntax">rows</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP63" class="paragraph-anchor"></a><b>&#167;63. External Files.</b>Inform has a quirky level of support for file-handling, which comes out of what
the Glulx virtual machine will support.
</p>

<p class="commentary">See test case <span class="extract"><span class="extract-syntax">BIP-Files-G</span></span>, which has no Z-machine counterpart.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">10</span><span class="plain-syntax"> - </span><span class="identifier-syntax">External</span><span class="plain-syntax"> </span><span class="identifier-syntax">Files</span><span class="plain-syntax"> (</span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">Z</span><span class="plain-syntax">-</span><span class="identifier-syntax">machine</span><span class="plain-syntax">)</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Files</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Text</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">write</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FN</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_writetext</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_PutContents</span><span class="plain-syntax">({</span><span class="identifier-syntax">FN</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">false</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">append</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">text</span><span class="plain-syntax">) </span><span class="identifier-syntax">to</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FN</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_appendtext</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_PutContents</span><span class="plain-syntax">({</span><span class="identifier-syntax">FN</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}, </span><span class="identifier-syntax">true</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="identifier-syntax">text</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">FN</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_saytext</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_PrintContents</span><span class="plain-syntax">({</span><span class="identifier-syntax">FN</span><span class="plain-syntax">}); </span><span class="identifier-syntax">say__p</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP64" class="paragraph-anchor"></a><b>&#167;64. </b>See test case <span class="extract"><span class="extract-syntax">BIP-FilesOfTables-G</span></span>, which has no Z-machine counterpart.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Files</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Data</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">read</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">into</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_readtable</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_GetTable</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">write</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> - </span><span class="identifier-syntax">table</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_writetable</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_PutTable</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, {</span><span class="identifier-syntax">T</span><span class="plain-syntax">}); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP65" class="paragraph-anchor"></a><b>&#167;65. </b>These are hardly used phrases which are difficult to test convincingly
in our framework, since they defend against independent Inform programs
simultaneously trying to access the same file.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax"> - </span><span class="identifier-syntax">File</span><span class="plain-syntax"> </span><span class="identifier-syntax">Handling</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">exists</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_fileexists</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">FileIO_Exists</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, </span><span class="identifier-syntax">false</span><span class="plain-syntax">)) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">ready</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">read</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_fileready</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- (</span><span class="identifier-syntax">FileIO_Ready</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, </span><span class="identifier-syntax">false</span><span class="plain-syntax">)) -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">mark</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">ready</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">read</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_markfileready</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_MarkReady</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, </span><span class="identifier-syntax">true</span><span class="plain-syntax">); -).</span>
<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">mark</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filename</span><span class="plain-syntax"> - </span><span class="identifier-syntax">external</span><span class="plain-syntax"> </span><span class="identifier-syntax">file</span><span class="plain-syntax">) </span><span class="identifier-syntax">as</span><span class="plain-syntax"> </span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">ready</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax"> </span><span class="identifier-syntax">read</span>
<span class="plain-syntax">    (</span><span class="identifier-syntax">documented</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ph_markfilenotready</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">FileIO_MarkReady</span><span class="plain-syntax">({</span><span class="identifier-syntax">filename</span><span class="plain-syntax">}, </span><span class="identifier-syntax">false</span><span class="plain-syntax">); -).</span>
</pre>
<p class="commentary firstcommentary"><a id="SP66" class="paragraph-anchor"></a><b>&#167;66. Use Options.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Chapter</span><span class="plain-syntax"> </span><span class="constant-syntax">11</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Use</span><span class="plain-syntax"> </span><span class="identifier-syntax">Options</span>

<span class="identifier-syntax">Section</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">Numerical</span><span class="plain-syntax"> </span><span class="identifier-syntax">Value</span>

<span class="identifier-syntax">To</span><span class="plain-syntax"> </span><span class="identifier-syntax">decide</span><span class="plain-syntax"> </span><span class="identifier-syntax">what</span><span class="plain-syntax"> </span><span class="identifier-syntax">number</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">numerical</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> (</span><span class="identifier-syntax">U</span><span class="plain-syntax"> - </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">use</span><span class="plain-syntax"> </span><span class="identifier-syntax">option</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    (- </span><span class="identifier-syntax">USE_OPTION_VALUES</span><span class="plain-syntax">--&gt;({</span><span class="identifier-syntax">U</span><span class="plain-syntax">}) -).</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="msdf.html">&#10094;</a></li><li class="progresssection"><a href="prmbl.html">prmbl</a></li><li class="progresssection"><a href="msdf.html">msdf</a></li><li class="progresscurrent">phdf</li><li class="progresssection"><a href="gag.html">gag</a></li><li class="progresssection"><a href="addf.html">addf</a></li><li class="progressnext"><a href="gag.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

